package red.mlz.module.module.tag.mapper;


import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import red.mlz.module.module.tag.entity.Tag;

import java.math.BigInteger;
import java.util.List;

/**
 * <p>
 * 分类表 Mapper 接口
 * </p>
 *
 * @author mlzred
 * @since 2025-04-06
 */
public interface TagMapper  {

    @Select("select * from tag WHERE id=#{id} and is_deleted = 0")
    Tag getById(@Param("id") BigInteger id);

    @Select("select * from tag WHERE id=#{id}")
    Tag extractById(@Param("id") BigInteger id);

    int update(@Param("Tag") Tag material);

    int insert(@Param("Tag") Tag material);

    @Update("update tag set is_deleted=1, update_time=#{time} where id=#{id} limit 1")
    void delete(@Param("id") BigInteger id, @Param("time") Integer time);

    List<Tag> listByNames(@Param("names") List<String> names);

    int insertBatch(@Param("tags")List<Tag> newTagNames);

    @Select("select * from tag WHERE id in (${tagIds}) ")
    List<Tag> listByIds(@Param("tagIds")String tagIds);
}
